import { defineStore } from "pinia";

interface UserState {
  userId: string;
  username: string;
  userPic: string;
}

export const useUserStore = defineStore("user", {
  state: (): UserState => ({
    userId: "",
    username: "",
    userPic: "",
  }),
  persist: {
    storage: localStorage, // 也可以使用 sessionStorage
  },
  actions: {
    setUserId(userId: string) {
      this.userId = userId;
    },
    setUsername(username: string) {
      this.username = username;
    },
    setUserPic(userPic: string) {
      this.userPic = userPic;
    },
  },
});
